package com.huiquan.framework.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import javax.servlet.http.HttpServletResponse;

public class TxtUtil {

	private static final String CONTENT_TYPE_TXT = "text/plain";
	private static final String HEADER_DIS = "Content-Disposition";
	private static final String HEADER_ATT = "attachment;filename=";
	private static final String FILE_SUFFIX_XLS = ".txt";

	public static void setTxtResp(HttpServletResponse resp, String fileName) throws UnsupportedEncodingException {
		resp.reset();
		resp.setContentType(CONTENT_TYPE_TXT);
		resp.setHeader(HEADER_DIS, HEADER_ATT + URLEncoder.encode(fileName, "UTF-8") + FILE_SUFFIX_XLS);
	}
}
